<template>
  <div class="member-center">
    <HeaderComponent 
      :isLoggedIn="userStore.isLoggedIn"
      :userInfo="userStore.userInfo"
      :showUserPanel="showUserPanel" 
      @toggle-user-panel="toggleUserPanel" 
      @logout="handleLogout"
    />
    
    <div class="container">
      <!-- 会员状态卡片 -->
      <div class="member-status-card">
        <div class="member-info">
          <div class="avatar">
            <img src="/touxiang.jpg" alt="用户头像">
          </div>
          <div class="user-details">
            <h3>admin</h3>
            <p class="member-level">掘金等级 JV.1</p>
            <div class="progress-bar">
              <div class="progress" style="width: 50%"></div>
            </div>
            <p class="progress-text">7.5 / 15</p>
          </div>
        </div>
        <div class="member-actions">
          <button class="upgrade-btn">升级会员</button>
        </div>
      </div>

      <!-- 会员权益 -->
      <div class="benefits-section">
        <h2>会员权益</h2>
        <div class="benefits-grid">
          <div class="benefit-card">
            <div class="benefit-icon">🎯</div>
            <h4>专属标识</h4>
            <p>会员专属身份标识</p>
          </div>
          <div class="benefit-card">
            <div class="benefit-icon">⚡</div>
            <h4>优先体验</h4>
            <p>新功能优先体验权</p>
          </div>
          <div class="benefit-card">
            <div class="benefit-icon">📚</div>
            <h4>专属内容</h4>
            <p>会员专享优质内容</p>
          </div>
          <div class="benefit-card">
            <div class="benefit-icon">🎁</div>
            <h4>专属福利</h4>
            <p>定期专属福利活动</p>
          </div>
        </div>
      </div>

      <!-- 订阅管理 -->
      <div class="subscription-section">
        <h2>订阅管理</h2>
        <div class="subscription-card">
          <div class="subscription-info">
            <h4>当前订阅</h4>
            <p>免费版</p>
            <p class="expire-date">无到期时间</p>
          </div>
          <div class="subscription-actions">
            <button class="subscribe-btn">立即订阅</button>
          </div>
        </div>
      </div>

      <!-- 会员特权 -->
      <div class="privileges-section">
        <h2>会员特权</h2>
        <div class="privileges-list">
          <div class="privilege-item">
            <div class="privilege-icon">💎</div>
            <div class="privilege-content">
              <h4>无广告浏览</h4>
              <p>享受纯净的阅读体验</p>
            </div>
            <div class="privilege-status locked">🔒</div>
          </div>
          <div class="privilege-item">
            <div class="privilege-icon">📖</div>
            <div class="privilege-content">
              <h4>专栏订阅</h4>
              <p>订阅喜欢的作者专栏</p>
            </div>
            <div class="privilege-status locked">🔒</div>
          </div>
          <div class="privilege-item">
            <div class="privilege-icon">🎨</div>
            <div class="privilege-content">
              <h4>主题定制</h4>
              <p>个性化界面主题</p>
            </div>
            <div class="privilege-status locked">🔒</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import HeaderComponent from '@/components/HeaderComponent.vue'
import { useUserStore } from '@/stores/user.js'

export default {
  name: 'MemberCenterView',
  components: {
    HeaderComponent
  },
  setup() {
    const userStore = useUserStore();
    return {
      userStore
    }
  },
  data() {
    return {
      showUserPanel: false
    }
  },
  methods: {
    toggleUserPanel() {
      this.showUserPanel = !this.showUserPanel
    },
    handleLogout() {
      this.userStore.logout();
      this.$router.push('/');
    }
  }
}
</script>

<style scoped>
.member-center {
  min-height: 100vh;
  background-color: #f4f5f5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* 会员状态卡片 */
.member-status-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.member-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.user-details h3 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
}

.member-level {
  color: #1e80ff;
  margin: 0 0 8px 0;
  font-weight: 500;
}

.progress-bar {
  width: 200px;
  height: 8px;
  background-color: #e4e6ea;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress {
  height: 100%;
  background: linear-gradient(90deg, #1e80ff, #00d4aa);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 14px;
  color: #8a919f;
  margin: 0;
}

.upgrade-btn {
  background: linear-gradient(135deg, #1e80ff, #00d4aa);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.upgrade-btn:hover {
  transform: translateY(-2px);
}

/* 会员权益 */
.benefits-section,
.subscription-section,
.privileges-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.benefits-section h2,
.subscription-section h2,
.privileges-section h2 {
  margin: 0 0 20px 0;
  font-size: 20px;
  font-weight: 600;
}

.benefits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.benefit-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  transition: transform 0.2s ease;
}

.benefit-card:hover {
  transform: translateY(-4px);
}

.benefit-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.benefit-card h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
}

.benefit-card p {
  margin: 0;
  color: #8a919f;
  font-size: 14px;
}

/* 订阅管理 */
.subscription-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
}

.subscription-info h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
}

.subscription-info p {
  margin: 0;
  color: #8a919f;
}

.expire-date {
  font-size: 14px;
}

.subscribe-btn {
  background: #1e80ff;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.subscribe-btn:hover {
  background: #0066cc;
}

/* 会员特权 */
.privileges-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.privilege-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.privilege-icon {
  font-size: 24px;
  width: 40px;
  text-align: center;
}

.privilege-content {
  flex: 1;
}

.privilege-content h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
}

.privilege-content p {
  margin: 0;
  color: #8a919f;
  font-size: 14px;
}

.privilege-status {
  font-size: 20px;
}

.privilege-status.locked {
  opacity: 0.5;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .member-status-card {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .benefits-grid {
    grid-template-columns: 1fr;
  }
  
  .subscription-card {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
}
</style>